package com.wanxi.fileandio.io;

import java.io.*;

public class ChangeType {
    public static void main(String[] args) {
        InputStreamReader inputStreamReader = null;
        OutputStreamWriter outputStreamWriter = null;
        try {
            File file1 = new File("changetest.txt");
            File file2 = new File("changetest111.txt");

            FileInputStream fileInputStream = new FileInputStream(file1);
            inputStreamReader = new InputStreamReader(fileInputStream);


            FileOutputStream fileOutputStream = new FileOutputStream(file2);//注意此处
            outputStreamWriter = new OutputStreamWriter(fileOutputStream);

            char[] cBuffer = new char[50];
            int len;
            while ((len = inputStreamReader.read(cBuffer)) != -1) {
                outputStreamWriter.write(cBuffer);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (outputStreamWriter != null)
                    outputStreamWriter.close();
                if (inputStreamReader != null)
                    inputStreamReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }
}
